package priv.bruce.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import priv.bruce.entry.MovieInfo;
import priv.bruce.service.MovieInfoService;


public class FindHomePageMovie extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private MovieInfoService movieInfoService = new MovieInfoService();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		try {
			List<MovieInfo> movieInfos = movieInfoService.findMovie();
			response.getWriter().append(JSON.toJSONString(movieInfos));
		} catch (Exception e) {

			e.printStackTrace();
		}
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("application/json;charset=utf-8");
		try {
			List<MovieInfo> movieInfos = movieInfoService.findMovie();
			response.getWriter().append(JSON.toJSONString(movieInfos));
		} catch (Exception e) {

			e.printStackTrace();
		}
	}
}
